package com.larry.spark.rdd.transform

import org.apache.spark.{SparkConf, SparkContext}

object RDD_Oper_MapPartitions_1 {

  def main(args: Array[String]): Unit = {
    //TODO  使用spark

    val conf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    val sc = new SparkContext(conf)

    val rdd = sc.makeRDD(
      List(1, 2, 3, 4),2
    )

    //分区最大值
    //返回结果可迭代
    val rdd1 = rdd.mapPartitions(
      list => {
        println("*****************")
        val max = list.max
        List(max).iterator
      }
    )

    rdd1.collect().foreach(println)

    sc.stop()
  }


}
